#ifndef COMMON_CONTAINER_HELPER_HPP
#define COMMON_CONTAINER_HELPER_HPP

#include <algorithm>

namespace Common
{

template <typename T, typename V>
bool contains(const T& container, const V& value)
{
    const auto end = container.end();
    return bool(end != std::find(container.begin(), end, value));
}

template <typename T>
typename T::mapped_type getDictValue(
    const T& container,
    const typename T::key_type& key,
    const typename T::mapped_type& defaultValue = typename T::mapped_type()
)
{
    if (0 != container.count(key))
        return container.at(key);
    return defaultValue;
}

} // namespace Common

#endif // COMMON_CONTAINER_HELPER_HPP
